#include "message2.h"

MessageInfoResponse::MessageInfoResponse()
{
    setMsgId(m_msgid);
}

MessageInfoResponse::MessageInfoResponse(const InfoData &info):m_Info(info)
{

}

MessageInfoResponse::~MessageInfoResponse()
{

}

uint32_t MessageInfoResponse::getBufferSize() const
{
    uint32_t size = IMessage::SERIALIZED_MSG_HEADER_SIZE;
    size += sizeof(uint32_t);
    size += sizeof(uint32_t);
    size += sizeof(uint8_t);
    size += sizeof(uint8_t);
    return size;
}

void MessageInfoResponse::serializeContent(uint8_t **bufPtr) const
{
    ValueToBuffer<uint32_t>(m_Info.height, bufPtr);
    ValueToBuffer<uint32_t>(m_Info.weight, bufPtr);
    ValueToBuffer<uint8_t>(m_Info.age, bufPtr);

    uint8_t married = 0;
    married = static_cast<uint8_t>(m_Info.married);
    ValueToBuffer<uint8_t>(married, bufPtr);
}

void MessageInfoResponse::deserializeContent(uint8_t **bufPtr)
{
    ValueFromBuffer<uint32_t>(bufPtr, m_Info.height);
    ValueFromBuffer<uint32_t>(bufPtr, m_Info.weight);
    ValueFromBuffer<uint8_t>(bufPtr, m_Info.age);

    uint8_t married = 0;
    ValueFromBuffer<uint8_t>(bufPtr, married);
    m_Info.married = static_cast<bool>(married);
}
